/**
 * https://leetcode-cn.com/problems/yong-liang-ge-zhan-shi-xian-dui-lie-lcof/submissions/
 * 两个栈实现队列
 */
class CQueue {
    // 入栈
  private in: number[]
  // 出栈
  private out: number[]
  private sizes = 0
  constructor() {
      this.in = []
      this.out = []
  }

  appendTail(value: number): void {
      this.in.push(value);
      this.sizes++
  }

  deleteHead(): number {
      if (this.sizes === 0) return -1

      this.sizes--; // sizes减一
      // out有值, 从out中取
      if (this.out.length) {
          return this.out.pop()!
      } else  {
          // 从in迁到out中
          while (this.in.length) {
              this.out.push(this.in.pop()!)
          }
          return this.out.pop()!
      } 
  }
}



class CQueue2 {
    private arr: number[]
    constructor() {
        this.arr = []
    }

    appendTail(value: number): void {
        this.arr.push(value)
    }

    deleteHead(): number {
        return this.arr.unshift() || -1
    }
}